// ++++++++++++++++++++++++++++++++++++++++
// 《Go 语言+Vue.js 实战派——基于 Gin 框架》源码
// ++++++++++++++++++++++++++++++++++++++++
// 作者公众号：源码大数据
// 自媒体账号（抖音、视频号、快手、B站、知乎）：廖显东-ShirDon
// 仓库地址：https://gitee.com/shirdonl/goGinVue.git
// 仓库地址：https://github.com/shirdonl/goGinVue.git
// 博客：https://www.shirdon.com
// 购买图书：https: //item.jd.com/14958064.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"time"
)

func main() {
	r := gin.Default()

	// 设置一个Cookie
	r.GET("/set-cookie", func(c *gin.Context) {
		cookie := &http.Cookie{
			Name:    "username",
			Value:   "shirdon",
			Expires: time.Now().Add(24 * time.Hour),
			Path:    "/",
		}
		http.SetCookie(c.Writer, cookie)
		c.String(http.StatusOK, "Cookie set successfully")
	})

	r.Run()
}
